package com.lovo.common.config;

import com.rabbitmq.client.AMQP;
import org.springframework.amqp.core.*;
import org.springframework.amqp.rabbit.annotation.EnableRabbit;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;


@Configuration
@EnableRabbit
public class TopicConfiguation {
    @Bean
    public Exchange topicExchange(){
        return new TopicExchange("shop.topic.exchange");
    }
    @Bean
    public Queue topicQueueA(){
        return new Queue("shop.topic.queue.a");
    }
    @Bean
    public Queue topicQueueB(){
        return new Queue("shop.topic.queue.b");
    }
    @Bean
    public Queue topicQueueC(){
        return new Queue("shop.topic.queue.c");
    }
    @Bean
    public Binding topicBindingA(){
        return BindingBuilder.bind(topicQueueA()).to(topicExchange()).with("rk.msg").noargs();
    }
    @Bean
    public Binding topicBindingB(){
        return BindingBuilder.bind(topicQueueB()).to(topicExchange()).with("rk.*").noargs();
    }
    @Bean
    public Binding topicBindingC(){
        return BindingBuilder.bind(topicQueueC()).to(topicExchange()).with("rk.#").noargs();
    }

}
